package org.krams.controller;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/")
public class MediatorController {

	@RequestMapping
	public String getHomePage() {
		return "home";
	}

	/*Content-Language	en
	 * http://java.sun.com/developer/technicalArticles/J2SE/locale/
	 * http://stackoverflow.com/questions/8478321/spring-security-i18n-how-to-make-it-work-together
	 */
	@RequestMapping(value = "/user")
	public String getUserPage(HttpServletRequest request,
			HttpServletResponse response, Locale locale) {
		System.out.println("req: " + request.getCharacterEncoding() + "/"
				+ request.getLocale().getLanguage() + " res: "
				+ response.getCharacterEncoding() + "/"
				+ response.getLocale().getLanguage() + " loc: "
				+ locale.getCountry() + "/" + locale.getLanguage());
		return "user";
	}

	@RequestMapping(value = "/admin")
	public String getAdminPage() {
		return "admin";
	}
}
